package org.proxypublic;

import java.lang.reflect.Method;

/**
 * Created by chinalin on 2017/3/17.
 */
public class ProxyPublic {
      private Object instance;

    public ProxyPublic(Class<?> cls ) {
        try {
            this.instance = cls.newInstance();
        }catch (Exception e){
            e.printStackTrace();
        }
    }

    public void say(Method method ,Object obj) {
        before();
        try {
            method.invoke(this.instance, obj) ;
        }catch (Exception e){
            e.printStackTrace();
        }
        after();
    }

    private void before(){
        System.out.println("Before");
    }
    private void after(){
        System.out.println("After");
    }
}
